package com.gopay.common.rcs.dao.dispute.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.domain.rcs.RcsDisputeOrderRecord;
import com.gopay.common.rcs.dao.dispute.RcsDisputeOrderRecordDAO;

/**
 * 纠纷记录
 * @RcsDisputeOrderRecordDAOImpl.java
 * @author mz
 * @Mar 6, 2014 5:11:27 PM  www.gopay.com.cn Inc.All rights reserved.
 */
@Repository("rcsDisputeOrderRecordDAO")
public class RcsDisputeOrderRecordDAOImpl extends BaseDAOImpl<RcsDisputeOrderRecord, Serializable>implements RcsDisputeOrderRecordDAO {

	@Override
	public RcsDisputeOrderRecord findRcsDisputeOrderRecordById(String id) {
		Map<String,Object> params = new HashMap<String,Object>();
        params.put("sq", id);
		List<RcsDisputeOrderRecord> l = super.findByHql("from RcsDisputeOrderRecord where sq=:sq ", params);
        return l.size() > 0 ? l.get(0) : null;
	}

	@Override
	public RcsDisputeOrderRecord findRcsDisputeOrderRecordByGopayOrderId(
			String gopayOrderId) {
		Map<String,Object> params = new HashMap<String,Object>();
        params.put("gopayOrderId", gopayOrderId);
		List<RcsDisputeOrderRecord> l = super.findByHql("from RcsDisputeOrderRecord where gopayOrderId=:gopayOrderId and merOrderId is null and bankOrderId is null ", params);
        return l.size() > 0 ? l.get(0) : null;
	}

	@Override
	public RcsDisputeOrderRecord findRcsDisputeOrderRecordByBankOrderId(
			String bankOrderId) {
		Map<String,Object> params = new HashMap<String,Object>();
        params.put("bankOrderId", bankOrderId);
		List<RcsDisputeOrderRecord> l = super.findByHql("from RcsDisputeOrderRecord where bankOrderId=:bankOrderId ", params);
        return l.size() > 0 ? l.get(0) : null;
	}

	@Override
	public RcsDisputeOrderRecord findRcsDisputeOrderRecordByMerOrderId(
			String merOrderId) {
		Map<String,Object> params = new HashMap<String,Object>();
        params.put("merOrderId", merOrderId);
		List<RcsDisputeOrderRecord> l = super.findByHql("from RcsDisputeOrderRecord where merOrderId=:merOrderId ", params);
        return l.size() > 0 ? l.get(0) : null;
	}

}
